/*
 * 
 * ....................................................................
 * ...######..#####.....##....####..#####..####..#####..######....##...
 * .....##....##..#....###...##.....##.....##....##..#....##.....###...
 * .....##....####....#.##....##....####...####..####.....##....#.##...
 * .....##....##.#...#####.....##...##.....##....##.#.....##...#####...
 * .....##....##..#.#...##..####....##.....####..##..#....##..#...##...
 * ....................................................................
 */

package ua.trasferta.common.utils;

import ua.trasferta.common.annotations.createBy;
import static ua.trasferta.common.team.TeamMember.*;

/**
 * <p>
 * If you wanna be so cool please check objects are not {@code null}.<br>
 * </p>
 * 
 * @author Anton Podviaznikov
 */
@createBy(authors = ANTON_PODVIAZNIKOV)
public final class Objects
{
	/**
	 * Private constructor.
	 */
	private Objects()
	{
		// hidden constructor.
	}

	/**
	 * If you wanna be so cool please check object is not {@code null}.
	 * 
	 * @param reference - an object reference.
	 * @return the non-null reference that was validated.
	 * @throws NullPointerException if {@code reference} is null.
	 */
	public static <T> T checkNotNull(T reference)
	{
		if (reference == null)
		{
			throw new NullPointerException();
		}
		return reference;
	}

	/**
	 * If you wanna be so cool please check objects are not {@code null}l.
	 * 
	 * @param references - an objects references.
	 * @return the non-null references that was validated.
	 * @throws NullPointerException if {@code references} is {@code null} or one
	 *             of the references is {@code null}.
	 */
	public static <T> T[] checkNotNull(T... references)
	{
		if ((references == null) || (references.length < 1))
		{
			throw new NullPointerException();
		}
		else
		{
			for (T reference : references)
			{
				Objects.checkNotNull(reference);
			}
		}
		return references;
	}
}
